package cn.iocoder.yudao.module.biz.controller.admin.invoice.service.impl;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.biz.controller.admin.invoice.domain.SanBizInvoiceManagement;
import cn.iocoder.yudao.module.biz.controller.admin.invoice.mapper.SanBizInvoiceManagementMapper;
import cn.iocoder.yudao.module.biz.controller.admin.invoice.service.SanBizInvoiceManagementService;
import cn.iocoder.yudao.module.biz.controller.admin.pay.domain.SanBizPaymentManagement;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 王兴鹏
* @description 针对表【san_biz_invoice_management(发票管理表)】的数据库操作Service实现
* @createDate 2025-08-23 01:56:31
*/
@Service
public class SanBizInvoiceManagementServiceImpl extends ServiceImpl<SanBizInvoiceManagementMapper, SanBizInvoiceManagement>
    implements SanBizInvoiceManagementService {

    @Autowired
    private SanBizInvoiceManagementMapper mapper;

    @Override
    public IPage<SanBizInvoiceManagement> getBizInvoiceManagementPage(SanBizInvoiceManagement pageReqVO) {
        QueryWrapper queryWrapper = new QueryWrapper();
        PageParam pageParam = new PageParam();
        pageParam.setPageNo(pageReqVO.getPageNo());
        pageParam.setPageSize(pageReqVO.getPageSize());
//        if(pageReqVO.getEffectDateStr() != null && pageReqVO.getEffectDateStr().size()> 1){
//            queryWrapper.ge("effect_date",pageReqVO.getEffectDateStr().get(0));
//            queryWrapper.le("effect_date",pageReqVO.getEffectDateStr().get(1));
//        }
        if(StringUtils.isNotEmpty( pageReqVO.getContractCode())){
            queryWrapper.like("contract_code", pageReqVO.getContractCode());
        }
        if(StringUtils.isNotEmpty( pageReqVO.getContractName())){
            queryWrapper.like("contract_name", pageReqVO.getContractName());
        }
        if(pageReqVO.getContractReceiveRecordId() != null){
            queryWrapper.eq("contract_receive_record_id", pageReqVO.getContractReceiveRecordId());
        }
        if(pageReqVO.getApproveStatus() != null){
            queryWrapper.eq("approve_status", pageReqVO.getApproveStatus());
        }
        queryWrapper.orderByDesc("create_time");
        IPage<SanBizInvoiceManagement> mpPage = MyBatisUtils.buildPage(pageParam);
        return mapper.selectPage(mpPage, queryWrapper);
    }
}




